const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const VueloaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
  entry: './src/main.js',
  output: {
    filename: 'js/[name]_[hash].js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      {test: /\.vue$/, loader: 'vue-loader'},
      {
        test: /\.js$/, loader: 'babel-loader',
        exclude: file => (/node_modules/.test(file) && !/\.vue\.js/.test(file))
      },
      {
        test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
        loader: 'url-loader',
        options: {
          limit: 8192
        }
      }
    ]
  },
  plugins: [
    new VueloaderPlugin(),
    new CleanWebpackPlugin(['dist']),
    new HtmlWebpackPlugin({
      title: 'App',
      filename: 'index.html',
      template: 'index.html',
      meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}
    }),
  ],
};